# encoding:utf-8
config = {
    "NCL_MPS:LEBT_VAC01:InST" : {
        "tree": "Vacuum",
        "value" : 0,
        "code" : 0x0101,
        "msg" : "LEBT-01",
    },
    "NCL_MPS:LEBT_VAC02:InST" : {
        "tree": "Vacuum",
        "value" : 0,
        "code" : 0x0102,
        "msg" : "LEBT-02",
    },
    "NCL_MPS:RFQ_VAC01:InST" : {
        "tree": "Vacuum",
        "value" : 0,
        "code" : 0x0103,
        "msg" : "RFQ-01",
    },
    "NCL_MPS:RFQ_VAC02:InST" : {
        "tree": "Vacuum",
        "value" : 0,
        "code" : 0x0104,
        "msg" : "RFQ-02",
    },
    "NCL_MPS:MEBT_VAC01:InST" : {
        "tree": "Vacuum",
        "value" : 0,
        "code" : 0x0105,
        "msg" : "MEBT-01",
    },
    "NCL_MPS:MEBT_VAC02:InST" : {
        "tree": "Vacuum",
        "value" : 0,
        "code" : 0x0106,
        "msg" : "MEBT-02",
    },
    "NCL_MPS:BD_CT:InST" : {
        "tree": "BeamDiagnostic",
        "value" : 0,
        "code" : 0x0201,
        "msg" : "CT-Diff",
    },
    "MEBT-LLRF:BPM1:X1Limited" : {
        "tree": "BeamDiagnostic",
        "value" : 0,
        "code" : 0x0202,
        "msg" : "BPM1-X1",
    },
    "MEBT-LLRF:BPM1:Y1Limited" : {
        "tree": "BeamDiagnostic",
        "value" : 0,
        "code" : 0x0203,
        "msg" : "BPM1-Y1",
    },
    "MEBT-LLRF:BPM1:X2Limited" : {
        "tree": "BeamDiagnostic",
        "value" : 0,
        "code" : 0x0204,
        "msg" : "BPM1-X2",
    },
    "MEBT-LLRF:BPM1:Y2Limited" : {
        "tree": "BeamDiagnostic",
        "value" : 0,
        "code" : 0x0205,
        "msg" : "BPM1-Y2",
    },
    "NCL_MPS:BD_TEMP:InST" : {
        "tree": "BeamLineTemp",
        "value" : 0,
        "code" : 0x0301,
        "msg" : "BeamLine-All",
    },
    "NCL_MPS:LLRF_RFQ:InST" : {
        "tree": "LLRF",
        "value" : 0,
        "code" : 0x0401,
        "msg" : "RFQ",
    },


    "NCL_SoftMPS:Occupancy_ratio:Status" : {
        "tree": "SoftMPS",
        "value" : 0,
        "code" : 0x0501,
        "msg" : "OccupRatio",
    },
    "NCL_SoftMPS:IS_Dip:Status" : {
        "tree": "SoftMPS",
        "value" : 0,
        "code" : 0x0502,
        "msg" : "PS-D1",
    },
    "NCL_SoftMPS:IS_SOL01:Status" : {
        "tree": "SoftMPS",
        "value" : 0,
        "code" : 0x0503,
        "msg" : "PS-SOL1 Status",
    },
    "NCL_SoftMPS:IS_SOL03:Status" : {
        "tree": "SoftMPS",
        "value" : 0,
        "code" : 0x0504,
        "msg" : "PS-SOL3 Current",
    },
    "NCL_SoftMPS:LEBT_PVV02:Status" : {
        "tree": "SoftMPS",
        "value" : 0,
        "code" : 0x0505,
        "msg" : "LEBT-PVV2",
    },
    "NCL_SoftMPS:RFQ_PVV07:Status" : {
        "tree": "SoftMPS",
        "value" : 0,
        "code" : 0x0506,
        "msg" : "LEBT-PVV7",
    },

    "NCL_SoftMPS:IS_FC:Status" : {
        "tree": "LFC&CHP-HV",
        "value" : 0,
        "code" : 0x0601,
        "msg" : "LFC-Fault",
    },
    "NCL_SoftMPS:IS_Chopper:Status" : {
        "tree": "LFC&CHP-HV",
        "value" : 0,
        "code" : 0x0602,
        "msg" : "CHP-Fault",
    },
    
    "NCL_BPS:Occupancy_ratio:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0701,
        "msg" : "OccupRatio",
    },
    "NCL_BPS:IS_Dip:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0702,
        "msg" : "PS-D1",
    },
    "NCL_BPS:IS_SOL01:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0703,
        "msg" : "PS-SOL1 Status",
    },
    "NCL_BPS:IS_SOL03:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0704,
        "msg" : "PS-SOL3 Current",
    },
    "NCL_BPS:Chopper_Trig:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0705,
        "msg" : "CHP-EXT&Width",
    },
    "NCL_BPS:Chopper_HV:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0706,
        "msg" : "CHP-HV",
    },
    "NCL_BPS:MWSRC_Width:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0707,
        "msg" : "NWS-EXT&Width",
    },
    "NCL_BPS:LEBT_PVV02:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0708,
        "msg" : "LEBT PVV2",
    },
    "NCL_BPS:RFQ_PVV07:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x0709,
        "msg" : "RFQ PVV7",
    },
    "NCL_BPS:Chopper_Total:Status" : {
        "tree": "BeamPermit",
        "value" : 0,
        "code" : 0x070A,
        "msg" : "CHP-State-Fault",
    },
    
}
prefix = 'iLinac_Warning:'
pvdb = {
    'Log_code' : {
        'prec' : 0,
        'scan' : 0,
        'count': 100,
    }
}

EPICS_CA_ADDR_LIST = "127.0.0.1:5066"
EPICS_CAS_SERVER_PORT = "5064"

def get_code(code):
    
    for data in config.values():
        if data["code"] == code:
            return [data["tree"],data["msg"]]
